package com.mustafaiev.tair.cts.tapestry.dto;

import java.io.Serializable;
import java.util.List;

import com.mustafaiev.tair.cts.model.Purchase;

/**
 * @author tair
 * 
 */
public class PayerDTO implements Serializable, Comparable<PayerDTO> {

    private static final long serialVersionUID = 4162713113037941975L;

    private Long id;

    private Long unitedKey;

    private List<BasketDTO> baskets;

    private List<Purchase> purchases;

    private String firstname;

    private String lastname;

    private String email;

    private String password;

    public PayerDTO() {

    }

    public Long getId() {
        return id;
    }

    public void setId(final Long id) {
        this.id = id;
    }

    public Long getUnitedKey() {
        return unitedKey;
    }

    public void setUnitedKey(final Long unitedKey) {
        this.unitedKey = unitedKey;
    }

    public List<BasketDTO> getBaskets() {
        return baskets;
    }

    public void setBaskets(final List<BasketDTO> baskets) {
        this.baskets = baskets;
    }

    public List<Purchase> getPurchases() {
        return purchases;
    }

    public void setPurchases(final List<Purchase> purchases) {
        this.purchases = purchases;
    }

    public String getFirstname() {
        return firstname;
    }

    public void setFirstname(final String firstname) {
        this.firstname = firstname;
    }

    public String getLastname() {
        return lastname;
    }

    public void setLastname(final String lastname) {
        this.lastname = lastname;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(final String email) {
        this.email = email;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(final String password) {
        this.password = password;
    }

    public int compareTo(final PayerDTO o) {

        if ((firstname != null) && (lastname != null)) {
            if (firstname.equals(o.getFirstname())
                    && lastname.equals(o.getLastname())) {
                return 0;
            }
            if ((firstname.compareTo(o.getFirstname()) >= 1)
                    || (lastname.compareTo(o.getLastname()) >= 1)) {
                return 1;
            }
            if ((firstname.compareTo(o.getFirstname()) < 0)
                    || (lastname.compareTo(o.getLastname()) < 0)) {
                return -1;
            }
        }
        return 0;
    }

}
